//package com.youlian.cloud.config;
//
//import com.netflix.zuul.ZuulFilter;
//import org.apache.commons.lang.StringUtils;
//import org.springframework.http.server.reactive.ServerHttpRequest;
//import org.springframework.stereotype.Component;
//import org.springframework.web.server.ServerWebExchange;
//
///**
// * 网关层面的过滤器，swagger的过滤器，主要是获取注册对应的项目名
// * @author liuhx
// * @create 2019/08/05 10:53
// * @email liuhx@elab-plus.com
// **/
//@Component
//public class SwaggerHeaderFilter extends ZuulFilter {
//
//    private static final String HEADER_NAME = "X-Forwarded-Prefix";
//
//    private static final String HOST_NAME = "X-Forwarded-Host";
//
//    @Override
//
//    public GatewayFilter apply(Object config) {
//
//        return (exchange, chain) -> {
//            ServerHttpRequest request = exchange.getRequest();
//            String path = request.getURI().getPath();
//            if (!StringUtils.endsWithIgnoreCase(path, "/v2/api-docs")) {
//                return chain.filter(exchange);
//            }
//            String basePath = path.substring(0, path.lastIndexOf("/v2/api-docs"));
//            ServerHttpRequest newRequest = request.mutate().header(HEADER_NAME, basePath).build();
//            ServerWebExchange newExchange = exchange.mutate().request(newRequest).build();
//            return chain.filter(newExchange);
//        };
//    }
//}